/**
 * Copyright (c) [2022] LiuGang(libbylg@126.com)
 * TinyEditor is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *             http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#include <iostream>

#include "vm.h"
#include "vm_impl.h"

int main(int argc, char* argv[]) {
    std::cout << "hello";
    vm_t* vm = vm_create();
    vm_inst_t codes[]{
        {VM_OP_SETB, VM_REG_1, 0, 0, 1},
        {VM_OP_SETB, VM_REG_2, 0, 0, 2},
        {VM_OP_IADDR, VM_REG_1, VM_REG_2, 0, 0},
        {VM_OP_COPY, VM_REG_0, VM_REG_1, 0, 0},
        {VM_OP_RETURN, 0, 0, 0, 0},
    };
    vm_load(vm, codes, sizeof(codes) / sizeof(codes[0]));

    uint64_t result = 0;
    int ret = vm_exec(vm, nullptr, 0, &result);
    ASSERT(ret == 0);
    ASSERT(result == 3);
    return 0;
}
